import 'package:flutter/material.dart';

class MyTextField extends StatelessWidget {
  final String text;
  final double height;
  var cb;   // 这个函数有参数  (value){}
  final bool obscureText; // 是否可见输入内容
  final int maxLines;

  MyTextField(
      {this.text = '请输入文字',
      this.height = 50,
      this.cb,
      this.obscureText = false,
      this.maxLines = 1});

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.only(left: 10),
      height: this.height,
      alignment: Alignment.center,
      decoration: BoxDecoration(
          border: Border.all(
        width: 1,
        color: Colors.black12,
      )),
      child: TextField(
        maxLines: this.maxLines,
        obscureText: this.obscureText,
        decoration: InputDecoration(
            contentPadding: EdgeInsets.all(0),
            hintText: this.text,
            border: InputBorder.none,
            hintStyle: TextStyle(fontSize: 14)),
        onChanged: cb,
      ),
    );
  }
}
